package com.jiao.store.controller;


import com.jiao.store.entity.Product;
import com.jiao.store.service.ProductService;
import com.jiao.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("product")
public class ProductController extends  BaseController{

    @Autowired
    private ProductService service;

    @RequestMapping("hostList")
     public JsonResult<List<Product>> getHostList(){
        List<Product> data = service.FindHostList();
        return new JsonResult<>(Ok,data);
    }


    @RequestMapping("{id}/details")
    public  JsonResult<Product> getById(@PathVariable("id")Integer id ){
        Product data = service.findById(id);

return new JsonResult<Product>(Ok,data);

    }
}
